<%--
  Created by IntelliJ IDEA.
  User: yingg_000
  Date: 2015/7/15
  Time: 14:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<!DOCTYPE HTML>
<html>

<head>
    <title>角色管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>
    用户管理 <span class="c-gray en">&gt;</span>
    用户列表 </nav>
<div class="pd-20">
    <div class="text-c">


        <input type="text"  placeholder=" 角色名" style="width:120px" class="input-text"id="rolename">&nbsp;&nbsp;&nbsp;
        <button  id="doSearch" class="btn btn-success radius" ><i class="Hui-iconfont">&#xe665;</i> 搜角色
        </button>

    </div>
    <table id="searchTable" style="margin-top:5px">
        <tr style="background-color:#a6c9e2;height:42px">
            <th colspan="10" scope="col" >
                   <span class="l"><a href="javascript:;" onClick="roleAdd()"
                                      class="btn btn-primary radius" ><i class="Hui-iconfont">&#xe600;</i> 添加</a>

        <a href="javascript:;" onClick="delRoles()" class="btn btn-danger radius" ><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a></span>

            </th>
        </tr>
        <tr>
            <th w_num="line" width="3%;"></th>
            <th w_check="true" w_index="unid" width="3%;"></th>
            <th w_index="rolename" w_sort="rolename" width="20%">角色名</th>
            <th w_index="createdate" w_sort="createdate"width="20%;">创建日期</th>
            <th w_index="createby" width="20%">创建者</th>
            <th w_render="operate" width="20%;">操作</th>
        </tr>
    </table>
</div>
</body>
</html>
<%@include file="../../head-ui.jsp" %>
<script type="text/javascript">
    var gridObj;
    $(function () {
        gridObj = $.fn.bsgrid.init('searchTable', {
            url: '<%=request.getContextPath()%>/back/role/list.do',
           // autoLoad: false,
            pageSizeSelect: true,
           pagingLittleToolbar: false,
            stripeRows: true,
            pageSize: 20,
            rowHoverColor: true,
            stripeRows: true,
            displayBlankRows: false
        });

        $("#doSearch").click(function () {
            doSearch();
        })
    });
    function doSearch() {
        var searchParames = { rolename: encodeURI($("#rolename").val())};
        gridObj.search(searchParames);
    }

    function operate(record, rowIndex, colIndex, options) {
        return "<a title='角色编辑' href='javascript:void(0)' " +
                "onClick=\"role_edit('" + record.unid+"')\" class='ml-5' style='text-decoration:none'><i class='Hui-iconfont'>&#xe6df;</i></a>" +

                "<a title='删除角色' href='javascript:void(0)' " +
                "onClick=\"role_del('" + record.unid + "')\" class='ml-5' style='text-decoration:none'><i class='Hui-iconfont'>&#xe6e2;</i></a>";
    }
    function role_edit(unid){

        layer_show("角色编辑","<%=request.getContextPath()%>/back/role/edit_page.do?unid="+unid,'500','510');
        <%--var index = layer.open({--%>
        <%--type: 2,--%>
        <%--title: '角色编辑',--%>
        <%--content: '<%=request.getContextPath()%>/role/edit_page.do?uuid='+uuid--%>
        <%--});--%>
        <%--layer.full(index);--%>
        <%--}--%>
    }
    function roleAdd(){
        layer_show('角色添加',$("#contextPath").val()+"/back/role/add_page.do",'500','400');
    };
    function role_del(unid){
        layer.confirm('确认要删除吗？',function(){
            $.post( $("#contextPath").val()+"/back/role/delete.do", {unid:unid}, function(res){
                if(res=="true"){
                    doSearch();
                    layer.msg('已删除!',{icon: 1,time:1000});
                }else{
                    layer.msg('删除失败!',{icon: 1,time:1000});
                }

            })
        });
    }
    function delRoles(){
        var unids = gridObj.getCheckedValues('unid');
        if(unids==null||unids==""){
            layer.msg('请选择需要删除的用户!',{icon: 1,time:1000});
        }else{
            layer.confirm('确认要删除吗？',function() {
                $.post($("#contextPath").val() + "/back/role/deletes.do", {unids: unids.join(',')}, function (res) {
                    if (res == "true") {
                        doSearch();
                        layer.msg('已删除!', {icon: 1, time: 1000});
                    } else {
                        layer.msg('删除失败!', {icon: 1, time: 1000});
                    }

                })
            })
        }
    }


</script>